﻿@model HmPMer.Entity.UserBaseInfo
@{
    ViewBag.Title = "首页";
    ViewBag.PageUri = "/index/index";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
    var OrderCountInfo = new HmPMer.Business.OrderBll().AgentCountTodayOrder(Model.UserId);
    var Notice = new HmPMer.Business.SystemBll().GetNewNoticeInfo(2, Model.UserId);
}

@section header{
    <link href="/static/css/compiled/index.css" rel="stylesheet" />
    <script src="/static/js/Chart/Chart.bundle.js"></script>
    <script src="/static/js/Chart/utils.js"></script>
    <script src="/static/js/popWinjs.js"></script>
}


<div class="container-fluid">
    <!-- upper main stats -->
    <div id="main-stats">
        <div class="row-fluid stats-row">
            <div class="span3 stat">
                <div class="data">
                    <span class="number">￥@((OrderCountInfo.TodayOrderAmt / 100).ToString("0.00"))</span>
                    订单金额
                </div>
                <span class="date">Today</span>
            </div>
            <div class="span2 stat">
                <div class="data">
                    <span class="number">@(OrderCountInfo.TodayOrderCount)</span>
                    订单数
                </div>
                <span class="date">Today</span>
            </div>
            <div class="span3 stat">
                <div class="data">
                    <span class="number">@((OrderCountInfo.CountPayOrderAmt / 100).ToString("0.00"))</span>
                    收益
                </div>
                <span class="date">Today</span>
            </div>

            <div class="span4 stat last">
                <div class="data">
                    <span class="number">￥@((Model.OrderAmt / 100).ToString("0.00"))</span>
                    累计交易金额
                </div>
                <span class="date">last all days</span>
            </div>
        </div>
    </div>
    <!-- end upper main stats -->
    <div id="pad-wrapper">

        <!-- statistics chart built with jQuery Flot -->
        <div class="chart-container">
            <canvas id="dataleft"></canvas>
        </div>
        <!-- end statistics chart -->

    </div>
</div>

<script>
    $(function () {

        $.HM.ajax("/Index/GetPayCountList", {

            data: {},
            type: "GET",
            dataType: 'json',
            success: function (data) {
                if (data) {
                    var color = Chart.helpers.color;
                    var config = {
                        type: 'line',
                        data: {
                            labels: data.CountDate,
                            datasets: [{
                                label: "订单总额",
                                backgroundColor: window.chartColors.green,
                                borderColor: window.chartColors.green,
                                borderWidth: 1,
                                data: data.CountOrderAmt
                            }, {
                                label: "支付订单总额" ,
                                backgroundColor: window.chartColors.blue,
                                borderColor: window.chartColors.blue,
                                data: data.CountPayOrderAmt,
                            }]
                        }
                        , options: {
                            responsive: true,
                            title: {
                                display: true,
                                text: '最近7日订单总额和支付订单总额'
                            },
                        }
                    };

                    var ctx = document.getElementById("dataleft").getContext('2d');
                    var config = config;
                    new Chart(ctx, config)

                }

            }
        });



        if ('@Notice.Id' != "" && '@Notice.IsRead' == 0) {
            popWin.showWin("/Feedback/Noticeinfo?Id=" + '@Notice.Id', 700, 350, function () { });
        }
    });

</script>